package com.jzo2o.foundations.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.IServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * @Author: beiqian
 * @Date: 2024-07-19 22:16
 * @Description: 运营端-区域服务管理相关的接口
 */
@Api(value = "/operation/serve", tags = {": 运营端-区域服务管理相关的接口"})
@RestController("operationServeController")
@RequestMapping("/operation/serve")
public class ServeController {

    @Resource
    private IServeService serveService;

    /**
     * 区域服务分页查询
     * @param servePageQueryReqDTO 分页查询相关数据
     * @return
     */

    @ApiOperation(value = "区域服务分页查询", notes = "区域服务分页查询", httpMethod = "GET")
    @GetMapping("/page")
    public PageResult<ServeResDTO> page(ServePageQueryReqDTO servePageQueryReqDTO){
        PageResult<ServeResDTO> page = serveService.page(servePageQueryReqDTO);
        return page;
    }

    /**
     * 添加区域服务
     * @param serveUpsertReqDTOList 服务列表
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "List<ServeUpsertReqDTO>", name = "serveUpsertReqDTOList", value = "服务列表", required = true)
    })
    @ApiOperation(value = "添加区域服务", notes = "添加区域服务", httpMethod = "POST")
    @PostMapping("/batch")
    public void add(@RequestBody List<ServeUpsertReqDTO> serveUpsertReqDTOList){
        serveService.batchAdd(serveUpsertReqDTOList);
    }

    /**
     * 修改区域服务
     * @param id 区域服务id主键
     * @param price 区域服务价格
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "long", name = "id", value = "区域服务id主键", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "BigDecimal", name = "price", value = "区域服务价格", required = true)
    })
    @ApiOperation(value = "修改区域服务", notes = "修改区域服务", httpMethod = "PUT")
    @PutMapping("/{id}")
    public void update(@PathVariable("id") Long id, @RequestParam("price") BigDecimal price){
        serveService.update(id, price);
    }

    /**
     * 删除指定id的区域服务
     * @param id 区域服务id
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "long", name = "id", value = "区域服务id", required = true)
    })
    @ApiOperation(value = "删除指定id的区域服务", notes = "删除指定id的区域服务", httpMethod = "DELETE")
    @DeleteMapping("/{id}")
    public void delete(@PathVariable("id") Long id){
        serveService.delete(id);
    }


    /**
     * 区域服务上架
     * @param id 区域服务id
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "long", name = "id", value = "区域服务id", required = true)
    })
    @ApiOperation(value = "区域服务上架", notes = "区域服务上架", httpMethod = "PUT")
    @PutMapping("/onSale/{id}")
    public void onSale(@PathVariable("id") Long id){
        serveService.onSale(id);
    }

    /**
     * 区域服务下架
     * @param id 区域服务id
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "long", name = "id", value = "区域服务id", required = true)
    })
    @ApiOperation(value = "区域服务下架", notes = "区域服务下架", httpMethod = "PUT")
    @PutMapping("/offSale/{id}")
    public void offSale(@PathVariable("id") Long id){
        serveService.offSale(id);
    }

    /**
     * 区域服务设置热门
     * @param id 区域服务id
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "long", name = "id", value = "区域服务id", required = true)
    })
    @ApiOperation(value = "区域服务设置热门", notes = "区域服务设置热门", httpMethod = "PUT")
    @PutMapping("/onHot/{id}")
    public void onHot(@PathVariable("id") Long id){
        serveService.onHot(id);
    }

    /**
     * 区域服务设置为 非热门
     * @param id 区域服务id
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "long", name = "id", value = "区域服务id", required = true)
    })
    @ApiOperation(value = "区域服务设置为 非热门", notes = "区域服务设置为 非热门", httpMethod = "PUT")
    @PutMapping("/offHot/{id}")
    public void offHot(@PathVariable("id") Long id){
        serveService.offHot(id);
    }
}
